-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(weave): Update ToggleButtonGroup to allow disabling individual options #3194
Conversation
if (newValue !== value) { | ||
if ( | ||
newValue !== value && | ||
options.find(option => option.value === newValue)?.isDisabled !== true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'pointer-events-none' didn't work to prevent the onChange from firing, so moved the isDisabled check here, and fixed it below to not show a pointer cursor
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=4e5437dc17429d3409e8faf2dbbec49134912ac6 |
key={optionValue} | ||
value={optionValue} | ||
disabled={isDisabled} | ||
asChild> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asChild is needed to prevent a validateDomNesting
error for nested buttons, see https://www.radix-ui.com/primitives/docs/guides/composition
@@ -9,6 +9,7 @@ import {Tailwind} from './Tailwind'; | |||
export type ToggleOption = { | |||
value: string; | |||
icon?: IconName; | |||
isDisabled?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added isDisabled
prop to specific options
(icon | ||
? 'gap-6 px-10 py-8 text-base' | ||
: 'px-12 py-8 text-base'), | ||
(isDisabled || optionIsDisabled) && 'cursor-auto opacity-35', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checks optionIsDisabled
and changes pointer-events-none
to cursor-auto
Description
Fixes nested button error in console, and fixes disabling individual options.
Testing
Tested on historic usage chart here https://github.com/wandb/core/pull/26192